
var JSonDtoModel = function(){
    this.state = 0;
    this.info = "成功";
    this.route = {};
    this.params = new Map();
    this.setState=function(state){
        this.state = state;
    };

    //set
    this.setInfo=function(info){
        this.info = info;
    };
    this.setState=function(state){
        this.state = state;
    };
    this.setParams=function(obj){
        this.params = new Map(obj);
    };

    // get

    this.getInfo=function(){
        return this.info;
    };

    this.getState=function(){
        return this.state;
    };
    this.getParams=function(){
        return this.params;
    };
    this.put=function(key,value){
        this.params.put(key,value);
    };

    this.get=function(key){
        return this.params.get(key);
    };
    this.clear = function(){
        this.state = 0;
        this.info = "成功";
        this.route = {};
        this.params = new Map();
    };
    this.setRoute = function(apiServer,call,description){
        if(arguments.length == 0){
            $.cc.error("路由信息错误");
            return;
        }
        var args = isArray(arguments[0]) ? arguments[0] : arguments;
        if(args.length == 1){
             call = args[0];
            this.route["call"]=call;
        }else if(args.length == 2){
             call = args[0];
             description = args[1];
            this.route["call"]=call;
            this.route["description"]=description;
        }else{
             apiServer = args[0];
             call = args[1];
             description = args[2];
            this.route["apiServer"]=apiServer;
            this.route["call"]=call;
            this.route["description"]=description;
        }
    };
    this.toJSONString=function(){
        var res = {};
        res["state"]=this.state;
        res["info"]=this.info;
        res["route"]=this.route;
        res["params"]=this.params.values();

        return JSON.stringify(res);
    };
    this.toString=function(){
        return this.toJSONString();
    };
};

JSonDtoModel.restore = function(str){
    var obj = JSON.parse(str);
    var dto = new JSonDtoModel();
    dto.setState(obj['state']);
    dto.setInfo(obj['info']);
    dto.setRoute(obj['route']);
    dto.setParams(obj['params']);

    return dto;
};

JSonDtoModel.clone = function(str){
    var dto = new JSonDtoModel();
    dto.setState(this.getState());
    dto.setInfo(this.getInfo());
    dto.setParams(this.getParams());
    return dto;
};
